package com.atguigu.userprofile.dao

import com.atguigu.userprofile.bean.TagInfo
import com.atguigu.userprofile.util.MysqlUtil

object TagInfoDAO {



  def getTagInfoByTaskId(taskId:String): TagInfo ={
    val sql=s"select * from tag_info ti where ti.tag_task_id='$taskId'"
    val maybeInfo: Option[TagInfo] = MysqlUtil.queryOne(sql, classOf[TagInfo], true)
    var tagInfo:TagInfo=null;

    if(maybeInfo!=None){
      tagInfo= maybeInfo.get
    }else{
      throw new RuntimeException("未查询出标签值")
    }

    tagInfo
  }

  //得到启用状态的标签list
  def   getTagInfoListWithOn(): List[TagInfo] ={
      val sql=
        s"""
           | select ti.* from tag_info ti join task_info tk on ti.tag_task_id = tk.id
           | where tk.task_status='1'
           |""".stripMargin
    val tagInfoList: List[TagInfo] = MysqlUtil.queryList(sql, classOf[TagInfo], true)

    tagInfoList

  }
}
